package cn.javass.dp.composite.example6;

import java.util.List;

/**
 * 抽象组件对象 ,为组合的对象声明接口，实现接口的缺省行为
 */

public abstract class Compoment {

    private  String compomentPath;

    public abstract String getName();


    public String getCompomentPath() {
        return compomentPath;
    }

    public void setCompomentPath(String compomentPath) {
        this.compomentPath = compomentPath;
    }

    /**
     * 记录组合对象之间的关系
     */
    private Compoment parent = null;

    public Compoment getParent() {
        return parent;
    }

    public void setParent(Compoment parent) {
        this.parent = parent;
    }

    public List<Compoment> getChildren() {
        throw new UnsupportedOperationException("对象不支持这个功能");
    }

    /**
     * 示意方法、子组件对象可能有的方法
     */
    public abstract void printStruct(String preName);

    public void addChild(Compoment child) {
        throw new UnsupportedOperationException("对象不支持这个功能");
    }

    public void removeChild(Compoment child) {
        throw  new UnsupportedOperationException("对象不支持这个功能");
    }

    public Compoment getChildren(int index) {
        throw  new UnsupportedOperationException("对象不支持这个功能");
    }

}
